package iterator;

import java.util.Iterator;

/**
 * @Author liangliangzhao
 * @data 2023/4/18 11:11
 */

public class ComputerCollegeIterator implements Iterator {
    // 迭代器  这里我们需要知道Department是以怎样的方法存放
    Department[] departments;
    int position = 0;// 遍历的位置
    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }
    public boolean hasNext() {
        if(position >= departments.length || departments[position] == null){
            return false;
        }else {
            return true;
        }
    }
    public Object next() {
        Department department = departments[position];
        position += 1;
        return department;
    }
    public void remove() {}// 删除的方法 默认空实现
}
